<? if (!defined("BASEPATH")) exit("No direct script access allowed");

class MessagesModel extends CI_Model {

    public function postMessage($content) {
        $user_id = $this->tank_auth->get_user_id();
        $data = array("content" => $content);
        $this->db->insert("messages", $data);
        $message_id = $this->db->insert_id();

        $this->db->flush_cache();

        $this->load->model('PostsModel');
        $this->PostsModel->insertPost("message", $message_id, $user_id);
    }
}
